using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Inventory.Domain.Models;

namespace Inventory.Database.Mapping
{
    public class PersonsProfessionMap : EntityTypeConfiguration<PersonsProfession>
    {
        public PersonsProfessionMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("PersonsProfessions");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.PersonId).HasColumnName("PersonId");
            this.Property(t => t.ProfessionId).HasColumnName("ProfessionId");

            // Relationships
            this.HasRequired(t => t.Person)
                .WithMany(t => t.PersonsProfessions)
                .HasForeignKey(d => d.PersonId);
            this.HasRequired(t => t.Profession)
                .WithMany(t => t.PersonsProfessions)
                .HasForeignKey(d => d.ProfessionId);

        }
    }
}
